addEvent("onInterakcjeWybierzAkcje", true)
addEventHandler("onInterakcjeWybierzAkcje", getRootElement(),
function(id, vehicle)
local veh = getPedOccupiedVehicle(source)
local recznySalon = getElementData(veh,"vehicle:salon")
local recznyPraca = getElementData(veh,"vehicle.praca")
	if veh then
		if getVehicleController(veh) == source then
			if id == 1 then
			if getElementData(veh,"vehicle:fuel") <= 0.0 then
			setVehicleEngineState(veh, false)
            else
			setVehicleEngineState(veh, true)
			end
			elseif id == 2 then
			setVehicleEngineState(veh, false)
			elseif id == 3 then
			setVehicleOverrideLights(veh, 2)
			elseif id == 4 then
			setVehicleOverrideLights(veh, 1)
			elseif id == 5 then
			setVehicleLocked(veh,false)
			elseif id == 6 then
			setVehicleLocked(veh,true)
			setVehicleDoorOpenRatio(veh, 2, 0, 2500)
			setVehicleDoorOpenRatio(veh, 3, 0, 2500)
			setVehicleDoorOpenRatio(veh, 4, 0, 2500)
			setVehicleDoorOpenRatio(veh, 5, 0, 2500)
		    elseif id == 9 then
			setVehicleDoorOpenRatio(veh,0,1,2000)
		    elseif id == 10 then
			setVehicleDoorOpenRatio(veh,0,0,2000)
            elseif id == 11 then
			setVehicleDoorOpenRatio(veh,1,1,2000)
			elseif id == 12 then
			setVehicleDoorOpenRatio(veh,1,0,2000)
		    elseif id == 13 then
			setVehicleDoorOpenRatio(veh,1,0,2000)	
			for seat, player in pairs(getVehicleOccupants(veh)) do
				if player then
 				if seat ~= 0 then
				setTimer(setControlState, 500, 1, player,"enter_exit", true)
				setTimer(setControlState, 1500, 1, player,"enter_exit", false)
				end
			    end
			end
			
			
   			elseif id == 7 then
			if recznySalon then 
         return 
end
           if getElementData(source, "pojazdF") then return end
			if recznyPraca then 
                     outputChatBox("* Nie możesz spuscić ręcznego!",source,255,0,0) 
         return 
end
			setElementFrozen(veh, false)
			elseif id == 8 then
local sx,sy,sz = getElementVelocity(veh)
local kmhs = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)
if kmhs < 20 then
if getElementModel(source) == 574 then return end
			 if getElementData(source, "pojazdF") then return end
			setElementFrozen(veh, true)
			end
		end
	else
		if vehicle then
			if isElement(vehicle) then
				if isVehicleLocked(vehicle) then
				setVehicleLocked(vehicle, false)
				else
				setVehicleLocked(vehicle, false)
				end
			end
		end
	end
end
end)

addEventHandler ( "onPlayerVehicleExit", getRootElement(), function(theVehicle, leftSeat, jackerPlayer)
    if leftSeat == 0 and not jackerPlayer then
      setVehicleLocked(theVehicle, false)
	  setElementData(theVehicle,"pasyzapiete",false)
	end
end)

